package wsi.function;

import org.rygh.core.face.IHasValue;

public class Url implements IHasValue<String> {

	private final String value;

	public Url(String value) {
		this.value = value;
	}

	@Override
	public String getValue() {
		return value;
	}

	/**
	 * support one parameters for now.
	 * 
	 * @param index
	 * @param value
	 * @param b
	 */
	public String reify(int index, String s, String convert) {
		if (convert == null || convert.isEmpty())
			convert = "%20";

		s = s.replaceAll("_", convert);
		s = s.replaceAll("\\s+", convert);

		return value.replace(String.format("[$%d]", index), s);
	}

	@Override
	public String toString() {
		return value;
	}
}
